# chmod 755 fileName.sh

# 设置签名环境 和 buildToolsVersion保持一致
signature_path="/Users/yang/Library/Android/sdk/build-tools/31.0.0"
# 加固之后的文件夹
reinforce_apk_path="/Users/yang/Downloads/360jiagutoolkits4_arm64/jiagu/output/18583342684"
# 签名文件
signature_file="/Users/yang/Desktop/yang_zones/公司项目/连点器/autoclick.jks"
# 签名别名
signature_alias="qjclick"
# 密码
password="123456"
# 输出路径
output_path="/Users/yang/Desktop/as"


echo "变量的值是: $signature_path"

cd $signature_path
for file in $(ls ${reinforce_apk_path});do
echo "${file}"

./zipalign -f -p -v 4 ${reinforce_apk_path}/${file} ${file} &&
cp  ${signature_path}/${file} ${signature_path}/lib/${file} &&
#cd lib&&
output_apk_path=${output_path}/${file}
echo "输出apk路径: $output_apk_path"
java -jar ${signature_path}/lib/apksigner.jar sign --ks ${signature_file}  --ks-key-alias  ${signature_alias} --ks-pass "pass:${password}" -out "${output_apk_path}" ${signature_path}/lib/${file}
done